

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xim/common/util/device.dart';
import 'package:xim/http/store.dart';

class GlobalStore with WidgetsBindingObserver{

  GlobalStore._(){
    WidgetsBinding.instance.addObserver(this);
  }

  static final GlobalStore instance = GlobalStore._();

  Brightness brightness = Brightness.light;

  updateBrightness({BuildContext? context}){
    context ??= Get.context;
    brightness = PlatformUtils.getBrightness(context!);
  }

  @override
  void didChangePlatformBrightness() {
    final window = WidgetsBinding.instance.window;
    print('----平台主题改变:$brightness`=>${PlatformUtils.getBrightness(Get.context!)}----');
    GlobalStore.instance.updateBrightness();
  }

  void dispose(){
    WidgetsBinding.instance.removeObserver(this);

  }


}


